import { seleLanguage } from '@/lang/index.js'
import { ref } from 'vue'

export const local = window.localStorage.getItem('locale') || navigator.language.slice(0, 2)

const localFlag = ref(local)

export function changeLocal (lang) {
 if (lang) {
  seleLanguage(['zh', 'en'].findIndex(item => item === lang))
  return
 }
 if (localFlag.value === 'zh') {
  seleLanguage(1)
 } else if (localFlag.value === 'en') {
  seleLanguage(0)
 }
}